//
//  PresetntationController.swift
//  Hunter
//
//  Created by oher on 15/7/6.
//  Copyright © 2015年 刘🐑. All rights reserved.
//

import UIKit



class PresetntationController: UIPresentationController {

    /// 展现视图的 frame
    var presentFrame = CGRectZero
    
    /// 遮罩视图
    lazy var maskView: UIView = {
        let v = UIView()
        //v.backgroundColor = UIColor(white: 0.0, alpha: 0.2)
        
        let tap = UITapGestureRecognizer(target: self, action: "close")
        v.addGestureRecognizer(tap)
    
        return v
        }()
    
    
    ///  关闭展现视图控制器
    func close() {
        presentedViewController.dismissViewControllerAnimated(true, completion: nil)
    }
    
    

    
    override init(presentedViewController: UIViewController, presentingViewController: UIViewController) {
    
        super.init(presentedViewController: presentedViewController, presentingViewController: presentingViewController)
    }
    
    
    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
        
        maskView.frame = (containerView?.frame)!
        //容器视图
        containerView?.insertSubview(maskView, atIndex: 0)
        //被展现出来的视图
        
        presentedView()?.frame = CGRectMake(UIScreen.mainScreen().bounds.width-150-10, 64, 150, 80)
    }
    
    
    
}
